package logger2.environment;

import java.awt.Color;
import java.util.Comparator;

import logger2.colorer.Colorer;
import logger2.colorer.FCcouple;
import logger2.filter.AcceptAllFilter;
import logger2.filter.Filter;
import logger2.filter.NameObjectKeyGetter;
import zerdlib.events.containers.ListenableSelfKeyTreeMap;
import zerdlib.events.containers.ListenableSet;

public class Environment {
	private static Comparator<String> caseInsensitiveComparator = new Comparator<String>() {
		@Override
		public int compare(String o1, String o2) {
			return o1.compareToIgnoreCase(o2);
		}
	};
	private ListenableSet<Filter> filterCatalog;
	private Filter defaultFilter;
	private ListenableSet<Colorer> colorerCatalog;
	
	private Filter currentFilter;
	private Colorer currentColorer;
	
	
	public Environment() {
		super();
		filterCatalog = new ListenableSelfKeyTreeMap<String, Filter>(new NameObjectKeyGetter(), caseInsensitiveComparator);
		currentFilter = defaultFilter = new AcceptAllFilter(this);
		filterCatalog.add(defaultFilter);
		
		colorerCatalog = new ListenableSelfKeyTreeMap<String, Colorer>(new NameObjectKeyGetter(), caseInsensitiveComparator);
		currentColorer = new Colorer(this, "Tout en noir");
		currentColorer.add(0, new FCcouple(defaultFilter, Color.black));
		colorerCatalog.add(currentColorer);
		
		
	}


	public Filter getDefaultFilter() {
		return defaultFilter;
	}


	public void setDefaultFilter(Filter defaultFilter) {
		this.defaultFilter = defaultFilter;
	}


	public Filter getCurrentFilter() {
		return currentFilter;
	}


	public void setCurrentFilter(Filter currentFilter) {
		this.currentFilter = currentFilter;
	}


	public Colorer getCurrentColorer() {
		return currentColorer;
	}


	public void setCurrentColorer(Colorer currentColorer) {
		this.currentColorer = currentColorer;
	}


	public ListenableSet<Filter> getFilterCatalog() {
		return filterCatalog;
	}


	public ListenableSet<Colorer> getColorerCatalog() {
		return colorerCatalog;
	}
	
	
	

}
